namespace Bmz.Studio.EntityFramework.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class Initial : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Abouts",
                c => new
                    {
                        Id = c.Int(nullable: false),
                        PersonId = c.Int(nullable: false),
                        Name = c.String(nullable: false, maxLength: 50),
                        Description = c.String(nullable: false, maxLength: 500),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Person", t => t.Id, cascadeDelete: true)
                .Index(t => t.Id);
            
            CreateTable(
                "dbo.Person",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 10),
                        Description = c.String(nullable: false, maxLength: 100),
                        Birthday = c.DateTime(nullable: false),
                        Address = c.String(nullable: false, maxLength: 50),
                        Position = c.String(maxLength: 50),
                        Phone = c.String(nullable: false, maxLength: 11),
                        Qq = c.String(nullable: false, maxLength: 10),
                        Email = c.String(nullable: false),
                        Website = c.String(maxLength: 200),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Contacts",
                c => new
                    {
                        Id = c.Int(nullable: false),
                        PersonId = c.Int(nullable: false),
                        GuestName = c.String(nullable: false, maxLength: 50),
                        GuestEmail = c.String(nullable: false, maxLength: 50),
                        Subject = c.String(nullable: false, maxLength: 50),
                        Message = c.String(nullable: false, maxLength: 500),
                        CreateDatetime = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Person", t => t.Id, cascadeDelete: true)
                .Index(t => t.Id);
            
            CreateTable(
                "dbo.Portfolios",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        PersonId = c.Int(nullable: false),
                        Name = c.String(nullable: false, maxLength: 50),
                        Description = c.String(nullable: false, maxLength: 500),
                        ImageUrl = c.String(nullable: false, maxLength: 500),
                        Type = c.String(nullable: false, maxLength: 50),
                        Order = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Person", t => t.PersonId, cascadeDelete: true)
                .Index(t => t.PersonId);
            
            CreateTable(
                "dbo.Resumes",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        PersonId = c.Int(nullable: false),
                        Name = c.String(nullable: false, maxLength: 50),
                        Description = c.String(nullable: false, maxLength: 500),
                        IsDefault = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Person", t => t.PersonId, cascadeDelete: true)
                .Index(t => t.PersonId);
            
            CreateTable(
                "dbo.Skills",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ResumeId = c.Int(nullable: false),
                        Name = c.String(nullable: false, maxLength: 50),
                        Percent = c.Single(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Resumes", t => t.ResumeId, cascadeDelete: true)
                .Index(t => t.ResumeId);
            
            CreateTable(
                "dbo.Works",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        PersonId = c.Int(nullable: false),
                        Name = c.String(nullable: false, maxLength: 50),
                        Description = c.String(nullable: false, maxLength: 500),
                        ImageUrl = c.String(nullable: false, maxLength: 500),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Person", t => t.PersonId, cascadeDelete: true)
                .Index(t => t.PersonId);
            
            CreateTable(
                "dbo.Dictionaries",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ParentId = c.Int(),
                        Code = c.String(nullable: false, maxLength: 10),
                        Name = c.String(nullable: false, maxLength: 20),
                        Type = c.String(nullable: false, maxLength: 10),
                        Description = c.String(maxLength: 200),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Navigations",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Code = c.String(nullable: false, maxLength: 10),
                        Name = c.String(nullable: false, maxLength: 10),
                        Description = c.String(nullable: false, maxLength: 50),
                        IsDelete = c.Boolean(nullable: false),
                        Order = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.Works", "PersonId", "dbo.Person");
            DropForeignKey("dbo.Resumes", "PersonId", "dbo.Person");
            DropForeignKey("dbo.Skills", "ResumeId", "dbo.Resumes");
            DropForeignKey("dbo.Portfolios", "PersonId", "dbo.Person");
            DropForeignKey("dbo.Contacts", "Id", "dbo.Person");
            DropForeignKey("dbo.Abouts", "Id", "dbo.Person");
            DropIndex("dbo.Works", new[] { "PersonId" });
            DropIndex("dbo.Skills", new[] { "ResumeId" });
            DropIndex("dbo.Resumes", new[] { "PersonId" });
            DropIndex("dbo.Portfolios", new[] { "PersonId" });
            DropIndex("dbo.Contacts", new[] { "Id" });
            DropIndex("dbo.Abouts", new[] { "Id" });
            DropTable("dbo.Navigations");
            DropTable("dbo.Dictionaries");
            DropTable("dbo.Works");
            DropTable("dbo.Skills");
            DropTable("dbo.Resumes");
            DropTable("dbo.Portfolios");
            DropTable("dbo.Contacts");
            DropTable("dbo.Person");
            DropTable("dbo.Abouts");
        }
    }
}
